<%@ page contentType="text/html;charset=UTF-8" language="java" import="java.sql.*"%>
<%@ page import="org.json.JSONArray" %>
<%@ page import="org.json.JSONObject" %>
<%
    
   // String id = request.getParameter("id");
     
    try{
    
    JSONArray jsonArray=new JSONArray();
	
    
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:DERMDDB", "der_stores", "derstores");
    Statement stmt = conn.createStatement();               
    String sql="select * from v_der_stores where rownum < 300 ";
    ResultSet rs=stmt.executeQuery(sql);
    while(rs.next()) {
       JSONObject jsonObject=new JSONObject();
       jsonObject.put("id",rs.getString(1));
       jsonObject.put("store",rs.getString("vstorename"));
       jsonObject.put("name",rs.getString("vcustname"));
       jsonObject.put("phone",rs.getString("vcusttel"));
       jsonObject.put("prov",rs.getString("vprovincename"));
       jsonObject.put("city",rs.getString("vcityname"));
       jsonObject.put("county",rs.getString("vcountyname"));
       jsonObject.put("town",rs.getString("vtownname"));
	   jsonObject.put("housenum", rs.getString("vhousenum"));
       jsonArray.put(jsonObject);
    }
    rs.close();
    stmt.close();
    conn.close();
	out.print(jsonArray.toString());
 
    }
catch (Exception e){
        out.print(e);
}
%>